<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ include file="../../base.jsp"%>
<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>数据 - AdminLTE2定制版</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 页面meta /-->
</head>
<body>
<div id="frameContent" class="content-wrapper" style="margin-left:0px;">
    <!-- 内容头部 -->
    <section class="content-header">
        <h1>
            个人管理
            <small>资料修改</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-dashboard"></i> 首页</a></li>

            <%--<li><a href="*">用户列表</a></li>--%>

        </ol>
    </section>
    <!-- 内容头部 /-->

    <!-- 正文区域 -->
    <section class="content">


        <div class="panel panel-default">
            <div class="panel-heading">用户信息</div>
            <form id="editForm1" action="/changeUser.do" method="post"  enctype="multipart/form-data">

                <input type="hidden" id="id" name="id" value="${user.id}">
                <%--<input type="hidden" id="deptName" name="deptName" value="${user.deptName}">--%>
                <div class="row data-type" style="margin: 0px">
                    <div class="col-md-2 title">用户名称</div>
                    <div class="col-md-4 data">
                        <input type="text" class="form-control" placeholder="用户名称" name="userName" value="${user.userName}">
                    </div>
                    <div class="col-md-2 title">邮箱</div>
                    <div class="col-md-4 data">
                        <input type="text" class="form-control" placeholder="邮箱" name="email" value="${user.email}">
                    </div>
                    <div class="col-md-2 title">密码</div>
                    <div class="col-md-4 data">
                        <input type="password" class="form-control" placeholder="密码" name="password" value="${user.password}">
                    </div>

                    <div class="col-md-2 title">性别</div>
                    <div class="col-md-4 data">
                        <div class="form-group form-inline">
                            <div class="radio"><label><input type="radio" ${user.gender==0?'checked':''} name="gender" value="0">男</label></div>
                            <div class="radio"><label><input type="radio" ${user.gender==1?'checked':''} name="gender" value="1">女</label></div>
                        </div>
                    </div>

                    <div class="col-md-2 title">电话</div>
                    <div class="col-md-4 data">
                        <input type="text" class="form-control" placeholder="电话" name="telephone" value="${user.telephone}" id="telephone">
                    </div>


                        <%--头像上传--%>
                    <div class="col-md-2 title">头像上传</div>
                    <div class="col-md-4 data">
                        <input type="file" class="form-control" placeholder="选择文件" name="file">
                    </div>
                    <div class="col-md-2 title">出生年月</div>
                    <div class="col-md-4 data">
                        <div class="input-group date">
                            <div class="input-group-addon">
                                <i class="fa fa-calendar"></i>
                            </div>
                            <input type="text" placeholder="出生年月" class="form-control pull-right" name="birthday"
                                   value="${user.birthday}" id="datepicker1">
                        </div>
                    </div>
                    <div class="col-md-2 title">说明</div>
                    <div class="col-md-4 data">
                        <input type="text" class="form-control" placeholder="说明" name="remark" value="${user.remark}">
                    </div>
                    <div class="col-md-2 title">
                        <a id="sendSmsCode">短信验证码</a>
                        <span id="sp1"></span>
                    </div>
                    <div class="col-md-4 data">
                        <input type="text" class="form-control" placeholder="请输入验证码" name="" value="" id="sms">
                    </div>
                    <div class="col-md-4 data">
                        <span id="sp2"></span>
                    </div>
                </div>
            </form>
        </div>


        <!--工具栏-->
        <div class="box-tools text-center">
            <button type="button" onclick='document.getElementById("editForm1").submit()' class="btn bg-maroon">保存</button>
            <button type="button" class="btn bg-default" onclick="history.back(-1);">返回</button>
        </div>
        <!--工具栏/-->

    </section>
    <!-- 正文区域 /-->

</div>
<!-- 内容区域 /-->
</body>
<script src="../../plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="../../plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<link rel="stylesheet" href="../../css/style.css">
<script>
    $('#datepicker').datepicker({
        autoclose: true,
        format: 'yyyy-mm-dd'
    });
    $('#datepicker1').datepicker({
        autoclose: true,
        format: 'yyyy-mm-dd'
    });
    $("#sendSmsCode").click(function () {
        let telephone = $("#telephone").val();
        let url="/system/user/sendSMS.do";
        let data="telephone=" + telephone;
        $.ajax({
            url : url,
            type : "post",
            dataType : "text",
            data : data,
            success : function (data) {
                if (data==-1){
                    $("#sp1").text("发送失败").css("color","red");
                }else {
                    $("#sp1").text("(发送成功)").css("color","green");
                }
            }
        })
    });
    $("#sms").blur(function () {
        let value = this.value;
        let telephone = $("#telephone").val();

        let url="/system/user/codeCheck.do";
        let data="telephone=" + telephone + "&value=" +value;
        $.ajax({
            url : url,
            type : "post",
            dataType : "text",
            data : data,
            success : function (data) {
                if (data=="false"){
                    $("#sp2").text("(验证码不正确)").css("color","red");
                }else {
                    $("#sp2").text("(验证成功)").css("color","green");
                }
            }
        })
    })
</script>
</html>